
from lib.api.Teacher import tm
from hytest import STEP, INFO, CHECK_POINT, GSTORE
from config.cfg import *


class Teacher1:
    name = '添加老师1 - tc001001'

    # 测试步骤
    def teststeps(self):
        STEP(1, "添加老师")

        classid = GSTORE['七一班-id']

        ret = tm.add_teacher(username='anran', realname="孙老师", subjectid=SUBJECT_ID_JUNIOR_CHINESE,
                             classlist=str(classid), phonenumber="1234567",
                             email="anran@163.com", idcardnumber="123123")

        retAdd = ret.json()
        INFO(retAdd)

        self.teacherid = retAdd['id']

        CHECK_POINT("添加老师检查", retAdd['retcode'] == 0)

        STEP(2, "列出老师")

        ret = tm.list_teacher(subjectid=SUBJECT_ID_JUNIOR_CHINESE)
        retList = ret.json()

        INFO(retList)

        CHECK_POINT("列出老师检查", retList['retlist'][0]['id'] == self.teacherid)

    def teardown(self):
        tm.delete_teacher(teacherid=self.teacherid)
